/*
 * @Description: 备份计划弹窗 - 备份类型面板
 * @Author: Rfan
 * @Date: 2022-08-03 20:29:15
 * @LastEditTime: 2022-08-04 17:19:11
 */

import { Checkbox, Form, Input, Radio, Space } from 'antd';

interface IBackupPlanProps {}

function BackupTypePane(props: IBackupPlanProps) {
  const [form] = Form.useForm();

  /**
   * @description: 提交表单方法
   * @param {any} values 表单数据
   */
  const onFinish = (values: any) => {
    //
  };

  const fullStrategy = (
    <Form.Item>
      <Space direction="vertical">
        <Radio>
          我将保存最后
          <Input />
        </Radio>
        <Checkbox>不删除第一个全量备份</Checkbox>
      </Space>
    </Form.Item>
  );

  const incrementalStrategy = (
    <Form.Item>
      <Checkbox.Group>
        <Space direction="vertical">
          <Checkbox>
            每<Input />
            次增量执行一次完全备份
          </Checkbox>
          <Checkbox>
            且在
            <Input />
            天后，删除之前的增量备份
          </Checkbox>
        </Space>
      </Checkbox.Group>
    </Form.Item>
  );
  return (
    <div className="backup-type-pane">
      <Form form={form} labelCol={{ span: 5 }} wrapperCol={{ span: 16 }} onFinish={onFinish}>
        <Form.Item name="type" label="备份方式" rules={[{ required: true }]}>
          <Radio.Group>
            <Radio value={1}>全量备份</Radio>
            <Radio value={2}>增量备份</Radio>
          </Radio.Group>
        </Form.Item>
        <Form.Item
          noStyle
          shouldUpdate={(prevValues, currentValues) => prevValues.type !== currentValues.type}
        >
          {({ getFieldValue }) =>
            getFieldValue('type') === 1 ? fullStrategy : incrementalStrategy
          }
        </Form.Item>
        <Form.Item label="压缩备份">
          <Radio.Group>
            <Radio value={1}>无</Radio>
            <Radio value={2}>一般</Radio>
            <Radio value={3}>快</Radio>
            <Radio value={4}>高</Radio>
          </Radio.Group>
        </Form.Item>
      </Form>
    </div>
  );
}

export default BackupTypePane;
